Dynamic data structures for tracking data stored in a flash memory device

ABSTRACT

One or more mapping data structures are maintained containing mappings of logical flash memory addresses to physical flash memory addresses. Each mapping data structure has a predetermined capacity of mappings. A master data structure is also maintained containing a pointer to each of the one or more mapping data structures. Additional mapping data structures are allocated as needed to provide capacity for additional mappings. Each time a mapping data structure is allocated or de-allocated the pointers in the master data structure are changed accordingly.

TECHNICAL FIELD

This invention relates to flash memory devices, and more particularly,management of data associated with flash memory devices.

BACKGROUND

Flash memory devices have many advantages for a large number ofapplications. These advantages include their non-volatility, speed, easeof erasure and reprogramming, small physical size and related factors.There are no mechanical moving parts and as a result such systems arenot subject to failures of the type most often encountered with harddisk storage systems. As a result many portable computer devices, suchas laptops, portable digital assistants, portable communication devices,and many other related devices are using flash memory as the primarymedium for storage of information.

Flash memory devices are generally operated by first setting all bits ina block to a common state, and then reprogramming them to a desired newstate. Blocks of data need to be shuffled during the reprogrammingprocess, which can slow the completion of the operation. Besides beingtime consuming, reprogramming a block of data can subject the entireblock to accidental loss, in the event there is a power failure duringthe reprogramming process. Normally, as the block is shuffled, it istemporarily stored in a volatile memory device, such as Random AccessMemory (RAM). The entire block of data (not just newly entered data) issusceptible to permanent loss if the reprogramming process has notcompleted prior to the power failure. In these circumstances, an entireblock of data may need to be reentered by a user anew.

SUMMARY

A dynamic data structure for tracking data stored in a Flash memorydevice is described. In a described implementation, a process maintainsone or more mapping data structures containing mappings of logical flashmemory addresses to physical flash memory addresses. Each mapping datastructure has a predetermined capacity of mappings. The process alsomaintains a master data structure containing a pointer to each of theone or more mapping data structures. Additional mapping data structuresare allocated as needed to provide capacity for additional mappings.Each time a mapping data structure is allocated or de-allocated thepointers in the master data structure are changed accordingly.

The described implementations, therefore, introduce the broad concept ofusing a dynamic amount of memory to store logical-to-physical sectoraddress mappings. Thus, the amount of memory needed to track data storedin the flash memory medium can be minimized.

BRIEF DESCRIPTION OF THE DRAWINGS

The detailed description is described with reference to the accompanyingfigures. In the figures, the left-most digit(s) of a reference numberidentifies the figure in which the reference number first appears.

FIG. 1 illustrates a logical representation of a NAND flash memorymedium.

FIG. 2 illustrates a logical representation of a NOR flash memorymedium.

FIG. 3 illustrates pertinent components of a computer device, which usesone or more flash memory devices to store information.

FIG. 4 illustrates a block diagram of flash abstraction logic.

FIG. 5 illustrates an exemplary block diagram of a flash medium logic.

FIG. 6A shows a data structure used to store a correspondingrelationship between logical sector addresses and physical sectoraddresses.

FIG. 6B shows a data structure which is the same as the data structurein FIG. 6B, except its contents have been updated.

FIG. 7 illustrates a process used to track data on the flash memorymedium when the file system issues write requests to the flash driver.

FIG. 8 illustrates a process for safeguarding mapping oflogical-to-physical sector address information stored in volatile datastructures, such as the data structures shown in FIGS. 6A and 6B.

FIG. 9 illustrates a location within the flash memory medium in whichthe logical sector address can be stored for safeguarding in the eventof a power failure.

FIG. 10 illustrates a dynamic look-up data structure to track datastored in the flash memory medium.

FIG. 11 illustrates a process for dynamically allocating look-up datastructures for tracking data on the flash memory medium.

FIG. 12 is a diagram of the flash memory medium viewed and/or treated asa continuous circle by the flash driver.

FIG. 13 depicts another illustration of the media viewed as a continuouscircle.

FIG. 14 illustrates a process used by the sector manager to determinethe next available free sector location for the flash driver to storedata on the medium.

FIG. 15 illustrates another view of media treated as a continuouscircle.

FIG. 16 is a flow chart illustrating a process used by the compactor torecycle sectors.

FIG. 17 shows one exemplary result from the process illustrated in FIG.16.

FIG. 18 illustrates a logical representation of a NOR flash memorymedium divided in way to better support the processes and techniquesimplemented by the flash driver.

DETAILED DESCRIPTION

The following discussion is directed to flash drivers. The subjectmatter is described with specificity to meet statutory requirements.However, the description itself is not intended to limit the scope ofthis patent. Rather, the inventors have contemplated that the claimedsubject matter might also be embodied in other ways, to includedifferent elements or combinations of elements similar to the onesdescribed in this document, in conjunction with other present or futuretechnologies.

Overview

This discussion assumes that the reader is familiar with basic operatingprinciples of flash memory media. Nevertheless, a general introductionto two common types of nonvolatile random access memory, NAND and NORFlash memory media, is provided to better understand the exemplaryimplementations described herein. These two example flash memory mediawere selected for their current popularity, but their description is notintended to limit the described implementations to these types of flashmedia. Other electrically erasable and programmable read-only memories(EEPROMs) would work too. In most examples used throughout this DetailedDescription numbers shown in data structures are in decimal format forillustrative purposes.

Universal Flash Medium Operating Characteristics

FIG. 1 and FIG. 2 illustrate logical representations of example NAND andNOR flash memory media 100, 200, respectively. Both media have universaloperating characteristics that are common to each, respectively,regardless of the manufacturer. For example referring to FIG. 1, a NANDflash memory medium is generally split into contiguous blocks (0, 1,through N). Each block 0, 1, 2, etc. is further subdivided into Ksectors 102; standard commercial NAND flash media commonly contain 8,16, or 32 sectors per block. The amount of blocks and sectors can vary,however, depending on the manufacturer. Some manufacturers refer to“sectors” as “pages.” Both terms as used herein are equivalent andinterchangeable.

Each sector 102 is further divided into two distinct sections, a dataarea 103 used to store information and a spare area 104 which is used tostore extra information such as error correction code (ECC). The dataarea 103 size is commonly implemented as 512 bytes, but again could bemore or less depending on the manufacturer. At 512 bytes, the flashmemory medium allows most file systems to treat the medium as anonvolatile memory device, such as a fixed disk (hard drive). As usedherein RAM refers generally to the random access memory family of memorydevices such as DRAM, SRAM, VRAM, VDO, and so forth. Commonly, the sizeof the area spare 104 is implemented as 16 bytes of extra storage forNAND flash media devices. Again, other sizes, greater or smaller can beselected. In most instances, the spare area 104 is used for errorcorrecting codes, and status information.

A NOR memory medium 200 is different than NAND memory medium in thatblocks are not subdivided into physical sectors. Similar to RAM, eachbyte stored within a block of NOR memory medium is individuallyaddressable. Practically, however, blocks on NOR memory medium canlogically be subdivided into physical sectors with the accompanyingspare area.

Aside from the overall layout and operational comparisons, someuniversal electrical characteristics (also referred to herein as “memoryrequirements” or “rules”) of flash devices can be summarized as follows:

1. Write operations to a sector can change an individual bit from alogical ‘1’ to a logical ‘0’, but not from a logical ‘0’ to logical ‘1’(except for case No. 2 below);

2. Erasing a block sets all of the bits in the block to a logical ‘1’;

3. It is not generally possible to erase individual sectors/bytes/bitsin a block without erasing all sectors/bytes within the same block;

4. Blocks have a limited erase lifetime of between approximately 100,000to 1,000,000 cycles;

5. NAND flash memory devices use ECC to safeguard against datacorruption due to leakage currents; and

6. Read operations do not count against the write/erase lifetime.

Flash Driver Architecture

FIG. 3 illustrates pertinent components of a computer device 300, whichuses one or more flash memory devices to store information. Generally,various different general purpose or special purpose computing systemconfigurations can be used for computer device 300, including but notlimited to personal computers, server computers, hand-held or laptopdevices, portable communication devices, multiprocessor systems,microprocessor systems, microprocessor-based systems, programmableconsumer electronics, gaming systems, multimedia systems, thecombination of any of the above example devices and/or systems, and thelike.

Computer device 300 generally includes a processor 302, memory 304, anda flash memory media 100/200. The computer device 300 can include morethan one of any of the aforementioned elements. Other elements such aspower supplies, keyboards, touch pads, I/O interfaces, displays, LEDs,audio generators, vibrating devices, and so forth are not shown, butcould easily be a part of the exemplary computer device 300.

Memory 304 generally includes both volatile memory (e.g., RAM) andnon-volatile memory (e.g., ROM, PCMCIA cards, etc.). In mostimplementations described below, memory 304 is used as part of computerdevice's 302 cache, permitting application data to be accessed quicklywithout having to permanently store data on a non-volatile memory suchas flash medium 100/200.

An operating system 309 is resident in the memory 304 and executes onthe processor 302. An example operating system implementation includesthe Windows®CE operating system from Microsoft Corporation, but otheroperation systems can be selected from one of many operating systems,such as DOS, UNIX, etc. For purposes of illustration, programs and otherexecutable program components such as the operating system areillustrated herein as discrete blocks, although it is recognized thatsuch programs and components reside at various times in differentstorage components of the computer, and are executed by the processor(s)of the computer device 300.

One or more application programs 307 are loaded into memory 304 and runon the operating system 309. Examples of applications include, but arenot limited to, email programs, word processing programs, spreadsheetsprograms, Internet browser programs, as so forth.

Also loaded into memory 304 is a file system 305 that also runs on theoperating system 309. The file system 305 is generally responsible formanaging the storage and retrieval of data to memory devices, such asmagnetic hard drives, and this exemplary implementation flash memorymedia 100/200. Most file systems 305 access and store information at alogical level in accordance with the conventions of the operating systemthe file system 305 is running. It is possible for the file system 305to be part of the operating system 309 or embedded as code as a separatelogical module.

Flash driver 306 is implemented to function as a direct interfacebetween the file system 305 and flash medium 100/200. Flash driver 306enables computer device 300 through the file system 305 to control flashmedium 100/200 and ultimately send/retrieve data. As shall be describedin more detail, however, flash driver 306 is responsible for more thanread/write operations. Flash driver 306 is implemented to maintain dataintegrity, perform wear-leveling of the flash medium, minimize data lossduring a power interruption to computer device 300 and permit OEMs ofcomputer devices 300 to support their respective flash memory devicesregardless of the manufacturer. The flash driver 306 is file systemagnostic. That means that the flash driver 306 supports many differenttypes of files systems, such as File Allocation Data structure FileSystem (FAT16), (FAT32), and other file systems. Additionally, flashdriver 306 is flash memory medium agnostic, which likewise means driver306 supports flash memory devices regardless of the manufacturer of theflash memory device. That is, the flash driver 306 has the ability toread/write/erase data on a flash medium and can support most, if notall, flash devices.

In the exemplary implementation, flash driver 306 resides as a componentwithin operating system 309, that when executed serves as a logicalinterface module between the file system 305 and flash medium 100/200.The flash driver 306 is illustrated as a separate box 306 for purposesof demonstrating that the flash driver when implemented serves as aninterface. Nevertheless, flash driver 306 can reside in otherapplications, part of the file system 305 or independently as separatecode on a computer-readable medium that executes in conjunction with ahardware/firmware device.

In one implementation, flash driver 306 includes: a flash abstractionlogic 308 and a programmable flash medium logic 310. Flash abstractionlogic 308 and programmable medium logic 310 are coded instructions thatsupport various features performed by the flash driver 306. Although theexemplary implementation is shown to include these two elements, variousfeatures from each of the flash abstraction logic 308 and flash mediumlogic 310 may be selected to carry out some of the more specificimplementations described below. So while the described implementationshows two distinct layers of logic 308/310, many of the techniquesdescribed below can be implemented without necessarily requiring all ora portion of the features from either layer of logic. Furthermore, thetechniques may be implemented without having the exact division ofresponsibilities as described below.

In one implementation, the Flash abstraction logic 308 manages thoseoperating characteristics that are universally common to flash memorymedia. These universal memory requirements include wear-leveling,maintaining data integrity, and handling recovery of data after a powerfailure. Additionally, the flash abstraction logic 308 is responsiblefor mapping information stored at a physical sector domain on the flashmemory medium 100/200 to a logical sector domain associated with thefile system 305. That is, the flash abstraction logic 308 tracks datagoing from a logical-to-physical sector addresses and/or from aphysical-to-logical sector addresses. Driver 306 useslogical-to-physical sector addresses for both read/write operations.Driver 306 goes from physical-to-logical sector addresses when creatinga look-up table (to be described below) during driver initialization.Some of the more specific commands issued by the file system that aredependent upon a certain type of flash memory media are sent directly tothe flash medium logic 310 for execution and translation. Thus, theflash abstraction logic 308 serves as a manager to those universaloperations, which are common to flash memory media regardless of themanufacturer for the media, such as wear-leveling, maintaining dataintegrity, handling data recovery after a power failure and so forth.

FIG. 4 illustrates an exemplary block diagram of the flash abstractionlogic 308. Flash abstraction logic 308 includes a sector manager 402, alogical-to-physical sector mapping module 404, and a compactor 406.Briefly, the sector manager 402 provides a pointer to a sectoravailable, i.e., “free” to receive new data. The logical-to-physicalsector mapping module 404 manages data as it goes from a file systemdomain of logical sector addressing to a flash medium domain of physicalsector addressing. The compactor 406 provides a mechanism for clearingblocks of data (also commonly referred to in the industry as “erasing”)to ensure that enough free sectors are available for writing data.Additionally, the compactor 406 helps the driver 306 system performuniform and even wear leveling. All these elements shall be described inmore detail below.

Referring back to FIG. 3, the flash medium logic 310 is used totranslate logical commands, received from either the flash abstractionlogic 308 or file system 305, to physical sector commands for issuanceto the flash memory medium 100/200. For instance, the flash medium logic310 reads, writes, and erases data to and/or from the flash memorymedium. The flash medium logic 310 is also responsible for performingECC (if necessary). In one implementation, the flash medium logic 310 isprogrammable to permit users to match particular flash mediumrequirements of a specific manufacturer. Thus, the flash medium logic310 is configured to handle specific nuances, ECC, and specific commandsassociated with controlling physical aspects of flash medium 100/200.

FIG. 5 illustrates an exemplary block diagram of the flash medium logic310. As shown, the flash medium logic 310 includes a programmable entrypoint module 502, I/O module 504 and an ECC module 506. The programmableentry point module 502 defines a set of programming interfaces tocommunicate between flash abstraction logic 308 and flash medium100/200. In other words, the programmable entry points permitmanufacturers of computer devices 300 to program the flash media logic310 to interface with the actual flash memory medium 100/200 used in thecomputer device 300. The I/O module 504 contains specific code necessaryfor read/write/erase commands that are sent to the Flash memory medium100/200. The user can program the ECC module 506 to function inaccordance with any particular ECC algorithm selected by the user.

Tracking Data

File system 305 uses logical sector addressing to read and storeinformation on flash memory medium 100/200. Logical sector addresses areaddress locations that the file system reads and writes data to. Theyare “logical” because they are relative to the file system. Inactuality, data may be stored in completely different physical locationson the flash memory medium 100/200. These physical locations arereferred to as physical sector addresses.

The flash driver 306 is responsible for linking all logical sectoraddress requests (i.e., read & write) to physical sector addressrequests. The process of linking logical-to-physical sector addresses isalso referred to herein as mapping. Going from logical to physicalsector addresses permits flash driver 306 to have maximum flexibilitywhen deciding where to store data on the flash memory medium 100/200.The logical-to-physical sector mapping module 404 permits data to beflexibly assigned to any physical location on the flash memory medium,which provides efficiency for other tasks, such as wear-leveling andrecovering from a power failure. It also permits the file system 305 tostore data in the fashion it is designed to do so, without needingintelligence to know that the data is actually being stored on a flashmedium in a different fashion.

FIG. 6A shows an exemplary implementation of a data structure (i.e., atable) 600A generated by the flash driver 306. The data structure 600Ais stored in a volatile portion of memory 304, e.g. RAM. The datastructure 600A includes physical sector addresses 602 that have acorresponding logical sector address 604. An exemplary description ofhow table 600A is generated is described with reference to FIG. 7.

FIG. 7 illustrates a process 700 used to track data on the flash memorymedium 100/200 when the file system 305 issues write requests to theflash driver 306. Process 700 includes steps 702–718. Referring to FIGS.6A and 7, in step 702, flash abstraction logic 308 receives a request towrite data to a specified logical sector address 604.

In step 704, the sector manager 402 ascertains a free physical sectoraddress location on the flash medium 100/200 that can accept dataassociated with the write request (how the sector manager 402 choosesphysical sector addresses will be explained in more detail below). Afree physical sector is any sector that can accept data without the needto be erased first. Once the sector manager 402 receives the physicalsector address associated with a free physical sector location, thelogical-to-physical sector mapping module 404 assigns the physicalsector address to the logical sector address 604 specified by writerequest forming a corresponding relationship. For example, a physicalsector address of 0 through N can be assigned to any arbitrary logicalsector address 0 through N.

Next, in step 706, the logical-to-physical sector mapping module 404stores the corresponding relationship of the physical sector address tothe logical sector address in a data structure, such as the exemplarytable 600A in memory 305. As shown in the exemplary data structure 600A,three logical sector addresses 604 are assigned to correspondingphysical sector addresses 602.

Next, in step 708 data associated with the logical sector address writerequest is stored on the flash medium 100/200 at the physical sectoraddress location assigned in step 704. For example, data would be storedin physical sector address location of zero on the medium 100/200, whichcorresponds to the logical sector address of 11.

Now, in step 710, suppose for example purposes the file system 305issues another write request, but in this case, to modify dataassociated with a logical sector address previously issued in step 702.Then, flash driver 306 performs steps 712 through 714, which areidentical to steps 704 through 708, respectively, which are describedabove.

In step 718, however, after the updated data associated with step 710 issuccessfully stored on the flash medium 100/200, the logical-to-physicalsector mapping module 404 marks the old physical sector address assignedin step 704 as “dirty.” Old data is marked dirty after new data iswritten to the medium 100/200, so in the event there is a power failurein the middle of the write operation, the logical-to-physical sectormapping module 404 will not lose old data. It is possible to lose new orupdated data from steps 702 or 710, but since there is no need toperform an erase operation only one item of new or modified data is lostin the event of a power failure.

FIG. 6B shows a data structure 600B which is the same as data structure600A, except its contents have been updated. In this example the filesystem 305 has updated data associated with logical sector address 11.Accordingly, the flash driver 306 reassigns logical sector address 11 tophysical sector address 3 and stores the reassigned correspondingrelationship between the these two addresses in data structure 600B. Asillustrated in data structure 600B, the contents of logical sector 11are actually written to physical sector address 3 and the contents ofsector 0 are marked “dirty” after the data contents are successfullywritten into physical sector address 3 as was described with referenceto steps 710–718.

This process of reassigning logical-to-physical sector address whenpreviously stored data is updated by the file system 305, permits writeoperations to take place without having to wait to move an entire blockof data and perform an erase operation. So, process 700 permits the datastructure to be quickly updated and then the physical write operationcan occur on the actual physical medium 100/200. Flash abstraction logic308 uses the data structures, such as 600A/600B, to correctly maintainlogical-to-physical mapping relationships.

When there is a read request issued by the files system 305, the flashabstraction logic 308, through the logical-to-physical mapping module404, searches the data structure 600A/600B to obtain the physical sectoraddress which has a corresponding relationship with the logical sectoraddress associated with read request. The flash medium logic 310 thenuses that physical sector address as a basis to send data associatedwith the read request back to the file system 305. The file system 305does not need intelligence to know that its requests to logical sectoraddresses are actually mapped to physical sector addresses.

Power-Interruption Protection

Write operations are performed at the sector-level as opposed to theblock-level, which minimizes the potential for data loss during apower-failure situation. A sector worth of data is the finest level ofgranularity that is used with respect to most file systems 305.Therefore, if the flash driver 306 is implemented to operate at a persector basis, the potential for data loss during a power failure isreduced.

As mentioned above, data structures 600A, 600B are stored in memory 304,which in one exemplary implementation is typically a volatile memorydevice subject to complete erasure in the event of a power failure. Tosafeguard data integrity on the flash medium 100/200,logical-to-physical mapping information stored in the data structures600A/600B is backed-up on the flash memory medium.

In one exemplary implementation, to reduce the cost associated withstoring the entire data structure on the flash memory medium 100/200,the logical sector address is stored in the spare 104 area of the mediumwith each physical sector in which the logical sector address has acorresponding relationship.

FIG. 8 illustrates a process 800 for safeguarding mapping oflogical-to-physical sector address information stored in volatile datastructures, such as exemplary data structures 600A and 600B. Process 800includes steps 802–814. The order in which the process is described isnot intended to be construed as a limitation. Furthermore, the processcan be implemented in any suitable hardware, software, firmware, orcombination thereof. In step 802, the logical sector address associatedwith the actual data is stored in the physical sector of the flashmemory medium 100/200 at the physical sector address assigned to thelogical sector address. In the case of a NAND flash memory medium 100,the logical sector address is stored in the spare area 104 of themedium. Using this scheme, the logical-to-physical sector mappinginformation is stored in a reverse lookup format. Thus, after a powerfailure situation, it is necessary to scan the spare area for eachphysical sector on the media, determine the corresponding logical sectoraddress, and then update the in-memory lookup table accordingly. FIG. 9illustrates a location with in media 100/200 in which the logical sectoraddress can be stored. As previously mentioned, blocks of NOR flashmemory can be logically subdivided into physical sectors each with aspare area (similar to NAND). Using this technique, the logical sectoraddress is stored in the spare area for each the physical sector similarto the process used with NAND flash memory (shown in FIG. 15 as space1504 to be described with reference to FIG. 15).

In the event there is a power interruption and the data structures 600A,600B are lost, as indicated by the YES branch of decisional step 804 ofFIG. 8, then flash abstraction logic 308 uses the flash medium logic 310to scan the flash memory medium to locate the logical sector addressstored with data in each physical address (see FIG. 9), as indicated instep 806. In step 808, the physical sector address in which data iscontained is reassigned to the logical sector address located with thedata on the medium. As the physical and logical sector address arereestablished they are stored back in the data structures 600A, 600B andthe flash medium logic 310 goes to the next sector containing data asindicated in step 812. Steps 806–812 repeat until all sectors containingdata have been are scanned and the data structure is reestablished.Normally, this occurs at initialization of the computer device 300.

Accordingly, when a power failure occurs, process 800 enables the flashabstraction logic 308 to scan the medium 100/200 and rebuild thelogical-to-physical mapping in a data structure such as the exemplarydata structure 600. Process 800 ensures that mapping information is notlost during a power failure and that integrity of the data is retained.

Dynamic Look-Up Data Structure for Tracking Data

FIG. 10 illustrates a dynamic look-up data structure 1000 to track datastored in the flash memory medium 100/200. Data structure 1000 includesa master data structure 1002 and one or more secondary data structures1004, 1006. The data structures are generated and maintained by theflash driver 306. The data structures are stored in a volatile portionof memory 304. The one or more secondary tables 1004, 1006 containmappings of logical-to-physical sector addresses. Each of the secondarydata structures 1004, 1006, as will be explained, have a predeterminedcapacity of mappings. The master data structure 1002 contains a pointerto each of the one or more secondary data structures 1004, 1006. Eachsecondary data structure is allocated on as needed basis for mappingthose logical-to-physical addresses that are used to store data. Oncethe capacity of a secondary data structure 1004, 1006, etc., isexceeded, another secondary data structure is allocated, and another,etc., until eventually all possible physical sector addresses on theflash medium 100/200 are mapped to logical sector addresses. Each time asecondary table is allocated, a pointer contained in the master datastructure 1002 is enabled by the flash driver 306 to point to it.

Accordingly, the flash driver 306 dynamically allocates one or moresecondary data structures 1004, 1006 based on the amount of permanentdata stored on the flash medium itself. The size characteristics of thesecondary data structures are computed at run-time using the specificattributes of the flash memory medium 100/200. Secondary data structuresare not allocated unless the secondary data structure previouslyallocated is full or insufficient to handle the amount of logicaladdress space required by the file system 305. Dynamic look-up datastructure 1000, therefore, minimizes usage of memory 304. Dynamiclook-up data structure 1000 lends itself to computer devices 300 thatuse calendars, inboxes, documents, etc. where most of the logical sectoraddress space will not need to be mapped to a physical sector address.In these applications, only a finite range of logical sectors arerepeatedly accessed and new logical sectors are only written when theapplication requires more storage area.

The master data structure 1002 contains an array of pointers, 0 throughN that point to those secondary data structures that are allocated. Inthe example of FIG. 10, the pointers at location 0 and 1 point tosecondary data structures 1004 and 1006, respectively. Also, in theexample illustration of FIG. 10, pointers 2 through N do not point toany secondary data structures and would contain a default setting,“NULL”, such that the logical-to-physical sector mapping module 404knows that there are no further secondary data structures allocated.

Each secondary data structure 1004, 1006 is similar to data structures600, but only a portion of the total possible medium is mapped in thesecondary data structures. The secondary data structures permit theflash abstraction logic 308 to reduce the amount space needed in memory304, to only those portions of logical sectors addresses issued by thefile system. Each secondary data structure is (b*k) bytes in size, wherek is the number of physical sector addresses contained in the datastructure and b is the number of bytes used to store each physicalsector address.

FIG. 11 illustrates a process 1100 for dynamically allocating look-updata structures for tracking data on the flash memory medium 100/200.Process 1100 includes steps 1102 through 1106. The order in which theprocess is described is not intended to be construed as a limitation.Furthermore, the process can be implemented in any suitable hardware,software, firmware, or combination thereof.

In step 1102, a master data structure 1002 containing the pointers toone or more secondary data structures 1004, 1006 is generated. Themaster data structure 1002 in this exemplary implementation is fixed insize. At the time the computer device 300 boots-up, the flash mediumlogic 310 determines the size of the flash memory medium 100/200 andrelays this information to the flash abstraction logic 308. Based on thesize of the flash medium, the flash abstraction logic 308 calculates arange of physical addresses. That is, suppose the size of the flashmedium is 16 MB, then a NAND flash medium 100 will typically contain32768 sectors each 512 bytes in size. This means that the flashabstraction logic 308 may need to map a total of 0 through 32768 logicalsectors in a worse case scenario, assuming all the memory space is usedon the flash medium. Knowing that there are 2¹⁵ sectors on the medium,the flash abstraction logic 308 can use 2 bytes to store the physicalsector address for each logical sector address. So the master datastructure is implemented as an array of 256 DWORDs (N=256), which coversthe maximum quantity of logical sector addresses (e.g., 32768) to beissued by the files system. So, there are a total of 256 potentialsecondary data structures.

In step 1104 the secondary data structure(s) are allocated. First, theflash abstraction logic determines the smallest possible size for eachpotential secondary data structure. Using simple division, 32768/256=128logical sector addresses supported by each data structure. As mentionedabove, the entire physical space can be mapped using 2 bytes, b=2,therefore, each secondary data structure will by 256 bytes in size or(b=2*k=128).

Now, knowing the size of each secondary data structure, suppose that thefile system 305 requests to write to logical sector addresses 50–79,also known as LS50–LS79. To satisfy the write requests from the filessystem 305, the flash abstraction logic 308 calculates that the firstpointer in master data structure 1002 is used for logical sectoraddresses LS0–LS127 or data structure 1004. Assuming the first pointeris NULL, the flash abstraction logic 308 allocates data structure 1004(which is 256 bytes in size) in memory 304. As indicated in step 1106,the flash abstraction logic 308 enables the pointer in position 0 of themaster data structure to point to data structure 1004. So, in thisexample, data structure 1004 is used to store the mapping informationfor logical sectors LS50–LS79.

The flash abstraction logic 308 allocates a secondary data structure, ifthe file system 305 writes to the corresponding area in the flash medium100/200. Typically, only the logical sector addresses that are used aremapped by the flash abstraction logic 308. So, in the worst casescenario, when the file system 305 accesses the entire logical addressspace, then all 256 secondary data structures (only two, 1004, 1006 areshown to be allocated in the example of FIG. 10), each 256 bytes in sizewill be allocated requiring a total of 64 KB of space in memory 304.

When an allocated data structure 1004, for instance, becomesinsufficient to store the logical sector address space issued by thefile system 305, then the flash abstraction logic 308 allocates anotherdata structure, like data structure 1006. This process of dynamicallyallocating secondary data structures also applies if data structure 1004becomes sufficient at a later time to again handle all the logicalsector address requests made by the file system. In this example, thepointer to data structure 1006 would be disabled by the flashabstraction logic 308; and data structure 1006 would become free spacein memory 304.

Uniform Wear Leveling and Recycling of Sectors

FIG. 12 is a diagram of flash memory medium 100/200 viewed and/ortreated as a continuous circle 1200 by the flash driver 306. Physicallythe flash memory media is the same as either media 100/200 shown inFIGS. 1 and 2, except the flash abstraction logic 308, organizes theflash memory medium as if it is a continuous circle 1200, containing0-to-N blocks. Accordingly, the highest physical sector address(individual sectors are not shown in FIG. 12 to simplify theillustration, but may be seen in FIGS. 1 and 2) within block N and thelowest physical sector address within block 0 are viewed as beingcontiguous.

FIG. 13 illustrates another view of media 100/200 viewed as a continuouscircle 1200. In this exemplary illustration, the sector manager 402maintains a write pointer 1302, which indicates a next available freesector to receive data on the medium. The next available free sector isa sector that can accept data without the need to be erased first in aprescribed order. The write pointer 1102 is implemented as a combinationof two counters: a sector counter 1306 that counts sectors and a blockcounter 1304 that counts blocks. Both counters combined indicate thenext available free sector to receive data.

In an alternative implementation, the write pointer 1302 can beimplemented as a single counter and indicate the next physical sectorthat is free to accept data during a write operation. According to thisimplementation, the sector manager 402 maintains a list of all physicalsector addresses free to receive data on the medium. The sector manager402 stores the first and last physical sector addresses (the contiguousaddresses) on the medium and subtracts the two addresses to determine anentire list of free sectors. The write pointer 1302 then advancesthrough the list in a circular and continuous fashion. This reduces theamount of information needed to be stored by the sector manager 402.

FIG. 14 illustrates a process 1400 used by the sector manager 402 todetermine the next available free sector location for the flash driver306 to store data on the medium 100/200. Process 1400 also enables thesector manager 402 to provide each physical sector address (for the nextfree sector) for assignment to each logical sector address write requestby the file system 305 as described above. Process 1400 includes steps1402–1418. The order in which the process is described is not intendedto be construed as a limitation. Furthermore, the process can beimplemented in any suitable hardware, software, firmware, or combinationthereof.

In step 1402, the X block counter 1304 and Y sector counter 1306 areinitially set to zero. At this point it is assumed that no data resideson the medium 100/200.

In step 1404, the driver 306 receives a write request and the sectormanager 402 is queried to send the next available free physical sectoraddress to the logical-to-physical sector mapping module 404. The writerequest may come from the file system 305 and/or internally from thecompactor 406 for recycling sectors as shall be explained in more detailbelow.

In step 1406, the data is written to the sector indicated by the writepointer 1302. Since both counters are initially set to zero in thisexemplary illustration, suppose that the write pointer 1302 points tosector zero, block zero.

In step 1408, the sector counter 1306 is advanced one valid sector. Forexample, the write pointer advances to sector one of block zero,following the example from step 1406.

Next, in decisional step 1410, the sector manager 402 checks whether thesector counter 1306 exceeds the number of sectors K in a block. If the Ycount does not exceed the maximum sector size of the block, thenaccording to the NO branch of decisional step 1410, steps 1404–1410repeat for the next write request.

On the other hand, if the Y count does exceed the maximum sector size ofthe block, then the highest physical sector address of the block waswritten to and the block is full. Then according to the YES branch ofstep 1410, in step 1412 the Y counter is reset to zero. Next, in step1414, X block counter 1304 is incremented by one, which advances thewrite pointer 1302 to the next block at the lowest valid physical sectoraddress, zero, of that block.

Next, in decisional step 1416, the compactor 406 checks whether the Xblock counter is pointing to a bad block. If it is, X block counter 1304is incremented by one. In one implementation, the compactor 406 isresponsible for checking this condition. As mentioned above, the sectormanager stores all of the physical sector addresses that are free tohandle a write request. Entire blocks of physical sector addresses arealways added by the compactor during a compaction or duringinitialization. So, the sector manager 402 does not have to check to seeif blocks are bad, although the sector manager could be implemented todo so. It should also be noted that in other implementations step 1416could be performed at the start of process 1400.

In step 1417, the X block counter 1304 is incremented until it ispointing to a good block. To avoid a continuous loop, if all the blocksare bad, then process 1400 stops at step 1416 and provides an indicationto a user that all blocks are bad.

Next in decisional step 1418, the sector manager checks whether the Xblock counter 1304 exceeds the maximum numbers of blocks N. This wouldindicate that write pointer 1302 has arrived full circle (at the top ofcircle 1200). If that is the case, then according to the YES branch ofstep 1418, the process 1400 repeats and the X and Y counter are reset tozero. Otherwise, according to the NO branch of step 1418, the process1400 returns to step 1404 and proceeds.

In this exemplary process 1400, the write pointer 1302 initially startswith the lowest physical sector address of the lowest addressed block.The write pointer 1302 advances a sector at a time through to thehighest physical sector address of the highest addressed block and thenback to the lowest, and so forth. This continuous and circular process1400 ensures that data is written to each sector of the medium 100/200fairly and evenly. No particular block or sector is written to more thanany other, ensuring even wear-levels throughout the medium 100/200.Accordingly, process 1400 permits data to be written to the nextavailable free sector extremely quickly without expensive processingalgorithms used to determine where to write new data while maintainingeven wear-levels. Such conventional algorithms can slow the write speedof a computer device.

In an alternative implementation, it is possible for the write pointer1302 to move in a counter clock wise direction starting with highestphysical sector address of the highest block address N and decrement itscounters. In either case, bad blocks can be entirely skipped and ignoredby the sector manager. Additionally, the counters can be set to anyvalue and do not necessarily have to start with the highest or lowestvalues of for the counters.

FIG. 15 illustrates another view of media 100/200 viewed as a continuouscircle 1200. As shown in FIG. 15, the write pointer 1302 has advancedthrough blocks 0 through 7 and is approximately half way through circle1200. Accordingly, blocks 0 through 7 contain dirty, valid data, or badblocks. That is, each good sector in blocks 0 through 7 is not free, andtherefore, not available to receive new or modified data. Arrow 1504represents that blocks 0 through 7 contain used sectors. Eventually, thewrite pointer 1302 will either run out of free sectors to write tounless sectors that are marked dirty or are not valid are cleared andrecycled. To clear a sector means that sectors are reset to a writablestate or in other words are “erased.” In order to free sectors it isnecessary to erase at least a block at a time. Before a block can beerased, however, the contents of all good sectors are copied to the freesectors to a different portion of the media. The sectors are then latermarked “dirty” and the block is erased.

The compactor 406 is responsible for monitoring the condition of themedium 100/200 to determine when it is appropriate to erase blocks inorder to recycle free sectors back to the sector manager 402. Thecompactor 406 is also responsible for carrying out the clear operation.To complete the clear operation, the compactor 406, like the sectormanager 402, maintains a pointer. In this case, the compactor 406maintains a clear pointer 1502, which is shown in FIG. 15. The clearpointer 1502 points to physical blocks and as will be explained enablesthe compactor 406 to keep track of sectors as the medium 100/200 asblocks are cleared. The compactor 406 can maintain a pointer to a blockto compact next since an erase operation affects entire blocks. That is,when the compactor 406 is not compacting a block, the compactor 406points to a block.

FIG. 16 is a flow chart illustrating a process 1600 used by thecompactor to recycle sectors. Process 1600 includes steps 1602–1612. Theorder in which the process is described is not intended to be construedas a limitation. Furthermore, the process can be implemented in anysuitable hardware, software, firmware, or combination thereof. In step1602, the compactor 406 monitors how frequently the flash memory medium100/200 is written to or updated by the file system. This isaccomplished by specifically monitoring the quantities of free and dirtysectors on the medium 100/200. The number of free sectors and dirtysectors can be determined counting free and dirty sectors stored intables 600 and/or 900 described above.

In decisional step 1604, the compactor 406 performs two comparisons todetermine whether it is prudent to recycle sectors. The first comparisoninvolves comparing the amount of free sectors to dirty sectors. If theamount of dirty sectors outnumbers the free sectors, then the compactor406 deems it warranted to perform a recycling operation, which in thiscase is referred to as a “service compaction.” Thus a service compactionis indicated when the number of dirty sectors outnumbers the quantity offree sectors.

If a service compaction is deemed warranted, then in step 1606 thecompactor waits for a low priority thread 1606, before seizing controlof the medium to carry out steps 1608–1612 to clear blocks of dirtydata. The service compaction could also be implemented to occur at otherconvenient times when it is optional to recycle dirty sectors into freesectors. For instance, in an alternative implementation, when one thirdof the total sectors are dirty, the flash abstraction logic 308 canperform a service compaction. In either implementation, usually thecompactor 406 waits for higher priority threads to relinquish control ofthe processor 302 and/or flash medium 100/200. Once a low prioritythread is available, the process proceeds to step 1608.

Referring back to step 1604, the second comparison involves comparingthe amount of free sectors left on the medium, to determine if the writepointer 1302 is about to or has run out of free sectors to point to. Ifthis is the situation, then the compactor 406 deems it warranted toorder a “critical compaction” to recycle sectors. The compactor does notwait for a low priority thread and launches immediately into step 1608.

In step 1608, the compactor 406 operates at either a high prioritythread or low priority thread depending on step 1604. If operating at ahigh level thread (critical compaction), the compactor 1102 is limitedto recycling a small number, e.g., 16 dirty sectors, into free sectorsand return control of the processor back to computer device 300 to avoidmonopolizing the processor 302 during such an interruption.

Thirty two sectors per block is commonly manufactured for flash media,but other numbers of sectors, larger or smaller, could be selected for acritical compaction. Regardless of these size characteristics, thenumber of sectors recycled during a critical compaction is arbitrary butmust be at least 1 (in order to satisfy the current WRITE request). Acritical compaction stalls the file system 305 from being able tocomplete a write; therefore, it is important to complete the compactionas soon as possible. In the case of a critical compaction, the compactor406 must recycle at least one dirty sector into a free sector so thatthere is space on the medium to fulfill the pending write request.Having more than one sector recycled at a time, such as 16, avoids thesituation where there are multiple pending write requests and multiplecritical compactions that are performed back-to-back, effectivelyblocking control of the processor indefinitely. So, while the number ofsectors recycled chosen for a critical compaction can vary, a numbersufficient to prevent back-to-back critical compactions is implementedin the exemplary description.

So, in step 1608, the compactor 406 will use the clear pointer 1502 toscan sectors for valid data, rewrite the data to free sectors, and marka sector dirty after successfully moving data. Accordingly, when movingdata, the compactor uses the same processes described with reference toprocess 700, which is the same code that is used when the file system305 writes new and/or updates data. The compactor 406 queries the sectormanager 402 for free sectors when moving data, in the same fashion asdescribed with reference to process 1400.

In step 1610, the compactor 406 moves the clear pointer 1502sector-by-sector using a sector counter like the write counter 1306shown in FIG. 13, except this sector counter pertains to the location ofthe clear pointer 1502. The compactor 406 also keeps track of blocksthrough a counter in similar fashion as described with reference to thewrite pointer 1302. However, the amount of blocks cleared is determinedby the number of dirty sectors with the exception of a criticalcompaction. In a critical compaction, the compactor only compacts enoughblocks to recycle a small number of physical sectors (i.e. 16 sectors).

In step 1612, the compactor erases (clears) those blocks which containgood sectors that are fully marked dirty. FIG. 17 shows exemplaryresults from process 1600. In this example, blocks 0 and 1 were clearedand the clear pointer was moved to the first sector of block 2, in theevent another compaction is deemed warranted. As a result, the compactor406 recycled two blocks worth of the sectors from blocks 0 and 1, whichprovides more free sectors to the sector manager 402. Used sectors 1504forms a data stream (hereinafter a “data stream” 1504) that rotates inthis implementation in a clockwise fashion. The write pointer 1302remains at the head of the data stream 1504 and the clear pointer 1502remains at the end or “tail” of the data stream 1504. The data stream1504 may shrink as data is deleted, or grow as new data is added, butthe pointers always point to opposite ends of the data stream 1504: headand tail.

Treating the flash memory medium as if the physical sector addressesform a continuous circle 1200, and using the processes described above,enables the flash abstraction logic 308 to accomplish uniformwear-leveling throughout the medium 100/200. The compactor 406 selects agiven block the same number times for recycling of sectors througherasure. Since flash blocks have a limited write/erase cycle, thecompactor as well as the sector manager distributes these operationsacross blocks 0-N as evenly and as fairly as possible. In this regard,the data steam 1504 rotates in the circle 1200 (i.e. the medium 100/200)evenly providing perfect wear-levels on the flash memory medium 100/200.

In the event of power failure, the flash abstraction logic 310 containssimple coded logic that scans the flash memory medium 100/200 anddetermines what locations are marked free and dirty. The logic is thenable to deduce that the data stream 1504 resides between the locationsmarked free and dirty, e.g., the data stream 1106 portion of the circle1200 described in FIG. 17. The head and tail of the data stream 1504 iseasily determined by locating the highest of the physical sectoraddresses containing data for the head and by locating the lowest of thephysical sector addresses containing data for the tail.

NOR Flash Devices

Although all the aforementioned sections in this Detailed Descriptionsection apply to NAND and NOR flash devices, if a NOR flash memorymedium 200 is used, some additional implementation is needed for theflash medium logic to support the storing of data in each physicalsector on the medium 200. Each NOR block 0, 1, 2, etc. can be treatedlike a NAND flash memory medium 100, by the flash medium logic 310.Specifically, each NOR block is subdivided into some number of pageswhere each page consists of a 512 byte “data area” for sector data andan 8 byte “spare area” for storing things like to the logical sectoraddress, status bits, etc. (as described above).

FIG. 18 illustrates a logical representation of a NOR flash memorymedium 200 divided in way to better support the processes and techniquesimplemented by the flash driver. In this implementation, sectors 1802contain a 512 byte data area 1803 for the storage of sector related dataand 8 bytes for a spare area 1804. Sections 1806 represent unusedportions of NOR blocks, because a NOR Flash block is usually a power of2 in size, which is not evenly divisible. For instance, consider a 16 MBNOR flash memory device that has 128 flash blocks each 128 KB in size.Using a page size equal to 520 bytes, each NOR flash block can bedivided into 252 distinct sectors with 32 bytes remaining unused.Unfortunately, these 32 bytes per block are “wasted” by the flash mediumlogic 310 in the exemplary implementation and are not used to storesector data. The tradeoff, however, is the enhanced write throughput,uniform wear leveling, data loss minimization, etc. all provided by theflash abstraction logic 308 of the exemplary flash driver 306 asdescribed above. Alternative implementations could be accomplished bydividing the medium 200 into different sector sizes.

Computer Readable Media

An implementation of exemplary subject matter using a flash driver asdescribed above may be stored on or transmitted across some form ofcomputer-readable media. Computer-readable media can be any availablemedia that can be accessed by a computer. By way of example, and notlimitation, computer readable media may comprise “computer storagemedia” and “communications media.”

“Computer storage media” include volatile and non-volatile, removableand non-removable media implemented in any method or technology forstorage of information such as computer readable instructions, datastructures, program modules, or other data. Computer storage mediaincludes, but is not limited to, RAM, ROM, EEPROM, flash memory or othermemory technology, CD-ROM, digital versatile disks (DVD) or otheroptical storage, magnetic cassettes, magnetic tape, magnetic diskstorage or other magnetic storage devices, or any other medium which canbe used to store the desired information and which can be accessed by acomputer.

“Communication media” typically embodies computer readable instructions,data structures, program modules, or other data in a modulated datasignal, such as carrier wave or other transport mechanism. Communicationmedia also includes any information delivery media.

The term “modulated data signal” means a signal that has one or more ofits characteristics set or changed in such a manner as to encodeinformation in the signal. By way of example, and not limitation,communication media includes wired media such as a wired network ordirect-wired connection, and wireless media such as acoustic, RF,infrared, and other wireless media. Combinations of any of the above arealso included within the scope of computer readable media.

Conclusion

Although the invention has been described in language specific tostructural features and/or methodological acts, it is to be understoodthat the invention defined in the appended claims is not necessarilylimited to the specific features or acts described. Rather, the specificfeatures and acts are disclosed as exemplary forms of implementing theclaimed invention.

1. In a computer device that uses flash memory to store data, a methodcomprising: maintaining one or more mapping data structures containingmappings of logical flash memory addresses to physical flash memoryaddresses, each mapping data structure having a predetermined capacity;allocating additional mapping data structures as needed to providecapacity for additional mappings; removing one or more additionallyallocated mapping data structures if the capacity of mappings is notneeded; and maintaining a master data structure containing a pointer toeach of the one or more mapping data structures, wherein the number ofpointers changes according to the number of data structures.
 2. Themethod as recited in claim 1, further comprising adding pointers to themaster data structure for the additionally allocated mapping datastructures.
 3. The method as recited in claim 1, wherein the mappingdata structures and master data structures are generated by a flashdriver.
 4. The method as recited in claim 1, wherein the mapping datastructures and master data structures are stored in a volatile memorydevice of the computer device.
 5. A system for tracking data in a flashmedium, comprising: a secondary data structure containing logical sectoraddress to physical sector address mappings showing a relationshipbetween logical sector addresses, requested by a file system, tophysical sector addresses in which associated data is physically storedon the flash medium; means for allocating a third data structure, if thesecondary data structure becomes full, wherein the third data structurecontains logical sector address to physical sector address mappings andfor deallocating the third data structure in the event the secondarydata structure is sufficient for mapping physical sector addressescontaining data to logical sector addresses; and a master data structurecontaining one or more pointers that point to the secondary datastructure and the third data structure, if allocated, wherein the numberof pointers changes as the third data structure is allocated anddeallocated.
 6. The system as recited in claim 5, further comprising aflash media driver configured to determine how many physical sectors arecontained on the flash medium.
 7. The system as recited in claim 5,wherein the means for allocating the third data structure is a flashdriver configured to monitor how many logical sector address requestsare issued by the file system to ensure there is enough datastructure(s) allocated in addition to the secondary data structure. 8.The system as recited in claim 5, further comprising means forallocating a fourth data structure, if the second and third datastructures are full.
 9. The system as recited in claim 6, wherein thedata structures are stored in a volatile memory device.
 10. A system,comprising: a master data structure containing 1 to N pointers, whereinN is an integer greater than 1; a secondary data structure containingmappings of logical sector addresses to physical sector addresses, thelogical sector addresses contained in the secondary data structure beinga portion of the maximum possible quantity of logical sector addressesthat can be issued by the file system; one or more additional datastructures containing mappings of logical sector addresses to physicalsector addresses, the one or more additional data structures beingallocated when the portion of logical sector addresses contained in thesecondary data structure is insufficient to store logical sector addresswrite requests issued by the file system and deallocated if the portionof logical sector addresses contained in the secondary data structurebecomes sufficient to store the logical sector address write requestsissued by the file system; and wherein the number of pointers in themaster data structure changes as the one or more additional datastructures are allocated and deallocated.
 11. The system as recited inclaim 10, further comprising a flash driver having a flash abstractionlayer configured to monitor logical sector address requests by the filesystem and update the mappings of logical sector addresses to physicalsector addresses.
 12. The system as recited in claim 10, wherein themaster and secondary data structures are stored in a volatile memorydevice.
 13. The system as recited in claim 10, wherein the master andsecondary data structures are stored in a random access device.
 14. Thesystem as recited in claim 10, further comprising a flash driverconfigured to determine a size of a flash medium.
 15. A computer device,comprising: a flash driver configured to serve as an interface between afile system and the flash memory medium; a waster data structurecontaining enough pointers to match a maximum quantity of logical sectoraddresses to be issued by the file system; a secondary data structurecontaining mappings of logical sector addresses to physical sectoraddresses, the logical sector addresses contained in the secondary datastructure being a portion of the maximum possible quantity of logicalsector addresses to be issued by the file system, wherein ones of thepointers from the master data structure point to specific mappings oflogical sector address to physical sector addresses in the secondarydata structure; and one or more additional data structures containingmappings of logical sector addresses to physical sector addresses,allocated by the flash driver when the portion of logical sectoraddresses contained in the secondary data structure is insufficient tostore logical sector address write requests issued by the file systemand deallocated by the flash driver if the portion of logical sectoraddresses contained in the secondary data structure becomes sufficientto store the logical sector address write requests issued by the filesystem, wherein others of the pointers from the master data structurepoint to specific mappings of logical sector address to physical sectoraddresses in the one or more additional data structures, such that thenumber of pointers in the master data structure pointing to the secondand additional data structures varies according to the number of datastructures.
 16. The computer device as recited in claim 15, wherein theflash driver comprises a flash abstraction layer configured to monitorlogical sector address requests by the file system and update themappings of logical sector addresses to physical sector addresses. 17.The computer device as recited in claim 15, wherein the master andsecondary data structures are stored in a volatile memory device. 18.The computer device as recited in claim 15, wherein the master andsecondary data structures are stored in a random access device.
 19. Thecomputer device as recited in claim 15 wherein the computer device is aportable data storage and processing device.
 20. In a computer devicethat uses flash memory to store data, a method comprising: generating amaster data structure containing a plurality of pointers; allocating asecondary data structure used to map logical sector addresses tophysical sector addresses, wherein the secondary data structure islimited in size; enabling one of the plurality of pointers to point tothe secondary data structure; allocating a third data structure used tomap logical sector addresses to physical sector addresses, if thesecondary data structure fills-up, and deallocating the third datastructure if the second data structure is no longer filled up; andenabling one of the plurality of pointers to point to the third datastructure, if allocated, such that the number of pointers pointing todata structures changes as the third data structure is allocated anddeallocated.
 21. The method as recited in claim 20, wherein the logicalsector addresses are issued by a file system and the physical sectoraddresses indicate where data associated with the logical sectoraddresses is physically stored on the flash medium.
 22. The method asrecited in claim 20, further comprising ascertaining a quantity ofphysical sectors on the flash medium prior to generating the secondarydata structure.
 23. The method as recited in claim 20, furthercomprising ascertaining a quantity of physical sectors on the flashmedium prior to generating the secondary data structure and determiningan address bit length for the pointers in relation to the quantity ofphysical sectors ascertained.
 24. The method as recited in claim 20,wherein the secondary data structure is b*k bytes in size, wherein k isa number of physical sector addresses contained in the data structureand b is a number of bytes required to store each physical sectoraddress.
 25. One or more computer-readable media comprisingcomputer-executable instructions that, when executed on the computerdevice, perform the method as recited in claim
 20. 26. The method asrecited in claim 20, wherein the computer device is a portableprocessing device.
 27. The method as recited in claim 20, wherein themethod is performed by a flash driver in conjunction with the filesystem of the computer device.
 28. The method as recited in claim 20,wherein the data structures are stored in a volatile memory portion ofthe computer device.
 29. The method as recited in claim 20, wherein thesecondary data structure fills-up when the logical sector addressesexceed the limited size of the secondary data structure.
 30. Acomputer-readable medium far a Flash driver, comprisingcomputer-executable instructions that, when executed, direct the Flashdriver to: generate a master data structure containing one or morepointers; allocate a secondary data structure used to map logical sectoraddresses to physical sector addresses, wherein the logical sectoraddresses are issued by a file system and the physical sector addressesindicate where data associated with the logical sector addresses isphysically stored on the flash medium; allocate a third data structureused to map logical sector addresses to physical sector addresses, ifthe secondary data structure fills-up, and deallocate the third datastructure if the second data structure is no longer filled up; andenable pointers from the master data structure to point to the secondand third data structures, wherein the number of pointers changes as thethird data structure is allocated and deallocated.
 31. Thecomputer-readable medium as recited in claim 30, further comprisingcomputer-executable instructions that, when executed, direct the Flashdriver to allocate one or more additional data structures in the eventthat the third data structure fills-up.
 32. A computer-readable mediumfor a Flash driver, comprising computer-executable instructions that,when executed, direct the Flash driver to: maintain one or more mappingdata structures containing mappings of logical flash memory addresses tophysical flash memory addresses, each mapping data structure having apredetermined capacity; allocate and deallocate additional mapping datastructures as capacity for additional mappings changes; and maintain amaster data structure containing at least one pointer to each of themapping data structures, wherein the number of pointers changesaccording to the number of data structures.